﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Admin2024.Domain.ObjValue
{
    public class DomainResult<T>
    {
        public bool IsSuccess { get; protected set; }

        public T Data { get; protected set; }

        public string Message { get; protected set; }


        public DomainResult(bool isSuccess, T data, string errorMessage)
        {
            IsSuccess = isSuccess;
            Data = data;
            Message = errorMessage;
        }

        public static DomainResult<T> Success(T data)
        {
            return new DomainResult<T>(true, data, "成功");
        }

        public static DomainResult<T> Error(string Msg)
        {
#pragma warning disable CS8604 // 引用类型参数可能为 null。
            return new DomainResult<T>(false, default, Msg);
#pragma warning restore CS8604 // 引用类型参数可能为 null。
        }
    }
}
